package com.zhentao.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zhentao.pojo.Store;
import com.zhentao.service.StoreService;
import com.zhentao.mapper.StoreMapper;
import com.zhentao.vo.StoreVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 86137
* @description 针对表【store】的数据库操作Service实现
* @createDate 2025-07-07 09:43:23
*/
@Service
public class StoreServiceImpl extends ServiceImpl<StoreMapper, Store>
    implements StoreService{

    @Autowired
    private AreaServiceImpl areaService;
    public Page<Store> StoreList(StoreVo storeVo) {
        LambdaQueryWrapper<Store> eq= Wrappers.<Store>lambdaQuery()
                .like(storeVo.getName()!=null,Store::getName,storeVo.getName())
                .eq(storeVo.getAreaId()!=0,Store::getAreaId,storeVo.getAreaId())
                .eq(storeVo.getStatus()!=0,Store::getStatus,storeVo.getStatus());
        Page<Store> page=this.page(new Page<>(storeVo.getPageNum(),storeVo.getPageSize()),eq);
        List<Store> records = page.getRecords();
        for (Store record : records){
            record.setAreaName(areaService.getById(record.getAreaId()).getName());
        }
        return page;
    }



}




